<template>
	<view class="qxlj_back2 contain">
		<view class="park_list" v-for="(item,index) in parkList" :key="index" @click="goDetail(item)">
			<image class="item_pic" :src="item.CoverImg" mode=""></image>
		</view>
	</view>
</template>

<script>
	import {
		getChildren
	} from '@/api/homePage.js';
	export default {
		data() {
			return {
				parkList: [],
			}
		},
		onLoad() {
			// this.postData();
			this.getGLDate();
			uni.showShareMenu({
				withShareTicket: true,
				//设置下方的Menus菜单，才能够让发送给朋友与分享到朋友圈两个按钮可以点击
				menus: ["shareAppMessage", "shareTimeline"]
			})
		},
		onShareAppMessage(res) {
			if (res.from === 'button') { // 来自页面内分享按钮
				console.log(res.target)
			}
			return {
				title: this.$category.appName, //分享的名称
				path: '/pages/index/parkList',
				mpId: this.$category.appid //此处配置微信小程序的AppId
			}
		},
		methods: {
			//跳转详情界面
			goDetail(e) {
				if (e.LinkUrl == "导航") {
					uni.openLocation({
						latitude: parseFloat(e.Lng),
						longitude: parseFloat(e.Lat),
						success: function(res) {
							console.log('打开系统位置地图成功')
						},
						fail: function(error) {
							console.log(error)
						}
					})
					return;
				}
				if (e.LinkUrl == null) return;
				if (e.LinkUrl == '/') {
					uni.showToast({
						title: '暂未开放',
						icon: 'none',
						duration: 2000
					});
					return
				}
				if (e.LinkUrl.includes('http') || e.LinkUrl.includes('https')) {
					uni.navigateTo({
						url: '/pages/webView/webView?url=' + e.LinkUrl
					})
					return;
				}
				if (e.LinkUrl.includes('pages/')) {
					uni.navigateTo({
						url: e.LinkUrl
					})
					return;
				};
			},
			//根据站点获取文章信息
			async getGLDate() {
				try {
					const Data = await getChildren({
						ArticleCategoryId: 3579,
					})
					this.parkList = Data.Data;
					console.log(this.parkList)
				} catch (e) {

				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.contain {
		width: 100%;
		height: 100vh;
		padding: 4%;
		padding-top: 2%;
	}

	.park_list {
		width: 100%;
		border-radius: 20rpx;
		height: 200rpx;
		margin-bottom: 30rpx;

		.item_pic {
			width: 100%;
			height: 100%;
			border-radius: 20rpx;
		}
	}
</style>